function   [ quantiles_output, y_avg_vec ] = gen_conditional_responses( x, y )
% Usage: post_processing( parameters,  model_sol )
% This function generates relevant results for a model solutiont(2D solutions with state variables (w, lambda)
N_quantiles=12;

quantiles = linspace( min(x)+0.2*range(x) ,  max(x),  N_quantiles )';
div = (quantiles(2)-quantiles(1))/2;
y_avg_vec = zeros(N_quantiles,1);
for( i = 1:N_quantiles )
y_avg_vec(i) = mean(    y( x>quantiles(i)-div &  x<quantiles(i)+div  )       );
end
quantiles_output = quantiles;

% quantiles = quantile(    x,   linspace( 0, 1, N_quantiles+1 )'    );
% y_avg_vec = zeros(N_quantiles,1);
% for( i = 1:N_quantiles )
% y_avg_vec(i) = mean(    y( x>=quantiles(i) &  x<=quantiles(i+1) )       );
% end
% temp=movmean( quantiles, 2 );
% quantiles_output = temp(2:(N_quantiles+1));